package com.mycompany.app.testsuite;

import java.io.File;
import java.io.FilenameFilter;

import org.apache.commons.lang.ArrayUtils;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class BaseTestUtils {
    static {
        File springConfigDir = new File(
                "D:\\personal\\sky-drive\\src\\main\\resources\\spring");
        File resourceDir = new File(
                "D:\\personal\\sky-drive\\src\\main\\resources");

        File[] s1 = springConfigDir.listFiles(new springConfigFileFilter());
        File[] s2 = resourceDir.listFiles(new springConfigFileFilter());
        File[] s3 = (File[]) ArrayUtils.addAll(s1, s2);
        String[] s = new String[s3.length];

        for (int i = 0; i < s3.length; i++) {
            s[i] = s3[i].getPath();
            System.out.println("Detect Spring Context File:" + s[i]);
        }
        System.out.println("Spring Container Initializing..............");
        FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(
                s);

    }

}

class springConfigFileFilter implements FilenameFilter {
    public boolean accept(File file, String s) {

        if (s.startsWith("applicationContext") && s.endsWith(".xml")) {
            return true;
        }
        return false;
    }

}
